package mka.puzzle.shape;

import java.awt.Graphics;
import java.util.ArrayList;

/***
 * Eclipse Standard Equation: (x/a)^2 + (y/b)^2 = 1
 * 
 * Focus Point F(-c,0)& F(c,0), c^2 = a^2 - b^2
 * 
 * General Equation: [(x-xc)/a]^2 + [(y-yc)/b]^2 = 1
 * 
 * Parameterize Equation:
 * 
 * x = xc + a * cos(t)
 * 
 * y = yc + b * sin(t)
 * 
 * @version 20131124
 * 
 * @author NguyenBB
 */
public class Eclipse extends Conic {
	/**
	 * 
	 */
	private double a;
	private double b;
	private double c;
	private Point center;

	/***************************************************************
	 * Constrtuctor.
	 ***************************************************************/
	public Eclipse() {
		this.a = 0;
		this.b = 0;
	}

	public Eclipse(int A, int B) {
		this.a = A;
		this.b = B;
	}

	public Eclipse(Point center, int A, int B) {
		this.center = new Point(center.getX(),center.getY());
		this.a = A;
		this.b = B;
	}

	/***************************************************************
	 * Set & Get method.
	 ***************************************************************/
	public double getA() {
		return a;
	}

	public void setA(double a) {
		this.a = a;
	}

	public double getB() {
		return b;
	}

	public void setB(double b) {
		this.b = b;
	}

	/***************************************************************
	 * Override from superclass.
	 ***************************************************************/
	@Override
	public boolean containBound(Point p) {
		if (Math.pow((p.getX() + this.center.getX()) / a, 2) + Math.pow((p.getY() - this.center.getY())/ b, 2) == 1)
			return true;
		return false;
	}

	@Override
	public boolean containShape(Point p) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public ArrayList<Point> allPointShape() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ArrayList<Point> allPointBound() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public double getPerimeter() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public double getArea() {
		// TODO Auto-generated method stub
		return 0;
	}

	/***************************************************************
	 * Draw and paint method.
	 ***************************************************************/
	/***
	 * draw.
	 * 
	 * Draw the Eclipse by java function
	 * 
	 * @param g Graphics
	 */
	@Override
	public void draw(Graphics g) {
		g.drawOval((int)this.center.getX(), (int)this.center.getY(), (int)this.a, (int)this.b);
	}
}